console.log('worker-同步任务')

setTimeout(() => {
  Promise.resolve().then((res) => {
    console.log('worker-宏任务中的微任务 - Promise in setTimeout 0')
  })
  console.log('worker-宏任务-setTimeout 0')
}, 0)

setTimeout(() => {
  Promise.resolve().then((res) => {
    console.log('worker-宏任务中的微任务 - Promise in setTimeout 1000')
  })
  console.log('worker-宏任务-setTimeout 1000')
}, 1000)

Promise.resolve().then((res) => {
  console.log('worker-微任务-Promise 1')
})

Promise.resolve().then((res) => {
  setTimeout(() => {
    console.log('worker-微任务中的宏任务 - setTimeout 0 in Promise 2')
  }, 0)
  setTimeout(() => {
    console.log('worker-微任务中的宏任务 - setTimeout 1000 in Promise 2')
  }, 1000)
  console.log('worker-微任务-Promise 2')
})

onmessage = (e) => {
  console.log('worker收到：' + e.data)
  postMessage(e.data)
}